#include "messagelist.h"

MessageList::MessageList(QWidget *parent)
    : QWidget{parent}
{
    setUI();
}

void MessageList::setUI()
{
    //水平布局
    hLayout = new QHBoxLayout();
    hLayout->setSpacing(0);
    hLayout->setContentsMargins(0,0,0,0);
    setLayout(hLayout);

    //司机身份
    driverBoxLayout = new QVBoxLayout();
    driverBoxLayout->setContentsMargins(0,0,0,0);
    driverBoxLayout->setSpacing(0);
    for (int i = 0; i < 4; i++) {
        driverLabel[i]= new QLabel();
        driverLabel[i]->setObjectName("driverLabel");
        driverLabel[i]->setAlignment(Qt::AlignCenter);
        driverBoxLayout->addWidget(driverLabel[i]);
    }

    //滚动信息
    listView = new QListWidget(this);
    listView->setFixedWidth(293);
    listView->setFixedHeight(124);
    listView->setObjectName("driverList");


    listView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    listView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    /* 设置为不可拖动 */
    listView->setDragEnabled(false);



    int fontId = QFontDatabase::addApplicationFont(":/images/iconfont.ttf");
    QString fontName = QFontDatabase::applicationFontFamilies(fontId).at(0);
    QFont iconFont = QFont(fontName);
    iconFont.setPixelSize(40);

    vLayout = new QVBoxLayout();
    vLayout->setSpacing(0);
    vLayout->setContentsMargins(0,0,0,0);

    for (int i = 0; i < 2; i++) {
        pushButton[i] = new QPushButton();
        pushButton[i]->setObjectName("upDownBtn");
        pushButton[i]->setFont(iconFont);
        pushButton[i]->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        pushButton[i]->setText(QChar(i== 0 ? 0xe644:0xe68c));
        vLayout->addWidget(pushButton[i]);
    }

    //添加到mode
    hLayout->addLayout(driverBoxLayout,66);
    hLayout->addWidget(listView,293);
    hLayout->addLayout(vLayout,57);
}
